<?php
namespace Advert\Model;
use Think\Model;
use Message\Core\Openfire;
use User\Model\UserModel;
class AdvertModel extends Model {
	protected $tableName 		= 'advert';
	protected $pk		 		= 'id';
	function _initialize(){
		
	}
    /**
     * @param $map
     * @param $limit
     * @param string $order
     * @return mixed
     * @explain:广告列表
     */
    function _list($map, $limit, $order='createtime desc'){
        return $this->where($map)->order($order)->limit($limit)->select();
    }

    function list_api($map, $limit, $order='createtime desc'){
        $result = $this->field(array('imgurl','imghref'))->where($map)->order($order)->limit($limit)->find();
        if(empty($result)){
            return showData($result ,'没有发布广告',1);
        }else{
            return showData($result ,'广告发布成功',0);
        }
    }

    function list_api_friend($map, $limit, $order='createtime desc'){
        $result = $this->field(array('id','imgurl','imghref','updatetime'))->where($map)->order($order)->limit($limit)->select();
        if(empty($result)){
            return array();
        }else{
            return $result;
        }
    }




}